<template>
    <div v-if="store.isLogin">
        <img :src="'http://localhost:9090/my/static/userimg/'+store.cur_user.photo" alt="">
        <span>{{store.cur_user.nickName}}</span>
        <span @click="logout">【注销】</span>
    </div>
    <div v-else>
        <router-link to="/login">【登录】</router-link>
    </div>
</template>

<script>
import {useUserStore} from '@/stores/userStore.js'
export default {
    data(){
        return {
           user:sessionStorage.getItem('curUser'),
           store:useUserStore()
        }
    },
    methods:{
        logout(){
            this.store.logout();
            // this.store.clearUser();
            // sessionStorage.removeItem("curUser");
            this.$router.push("/login");
        }
    }
}
</script>

<style scope>
    img{
        width: 50px;
        height: 50px;
    }
</style>